<?php
        define("GRID_SOURCE", "");
        include(GRID_SOURCE."class/gridclasses.php"); //Include the grid engine.

        session_start();
        require_once "../funciones.php";
        $link_caweb = con_caweb();
        //$link_intranetpccom = con_intranetpccom();
        $grid_id = array("grid");
        unset($_SESSION["grid"]);
        include(GRID_SOURCE."class/gridcreate.php"); //Creates grid objects.
        
        $transaccion=$_SESSION['caweb']['consecutivo'];
        
?>
<html>
        <head>
                <title>View Grid</title>
                <script language="Javascript" type="text/javascript" src="<?php print(GRID_SOURCE);?>javascript/javascript.js"></script>
                <link href="<?php print(GRID_SOURCE);?>css/style.css" rel="stylesheet" type="text/css">
                <link rel="stylesheet" type="text/css" media="screen" href="../css/caweb.css" />
				<script type='text/javascript' src="<?php print(GRID_SOURCE);?>server.php?client=all"></script>
				<script>
				HTML_AJAX.defaultServerUrl = '<?php print(GRID_SOURCE);?>server.php';
				</script>
		<script src="caweb2.js"></script>
		<script type="text/javascript" src="jquery.js"></script>
		<script languaje=\"Javascript\">
		function valida( formulario ) {
		   if (formulario.clasetx.value == "") {
  				alert('Debe Seleccionar una Clase');
				$("#clase").focus();
				return false;
  				}
			if (formulario.cobrar.value == "Si" && (formulario.tarifa.value == "" || formulario.tarifa.value == "0")) {
  				alert('Ingrese Tarifa, ya que selecciono que se debe cobrar');
				$("#tarifa").focus();
				return false;
  				}
  			return true;
			}		
		</script>
		
        </head>
        <body>

	<?php
		$result ="SELECT * FROM temporal_ped WHERE transaccion = '$transaccion'";
		$result=mysql_query($result,$link_caweb) or die('Error temporal_ped, '.mysql_error());
		$totalpresuntos=mysql_num_rows($result);
        echo "<script languaje='Javascript'>  $('#presuntos', top.document).attr('value','".$totalpresuntos."'); </script>";
        
	if ($_SESSION['caweb']['iniciar'] == 1)
	{
	?>
		<form name="pedidos" method="POST" action="adiciona_ped.php" onSubmit="return valida(this);">
                    <table>
                        <tr>
                            <td>
                                <div><label for="clasetx">Clase</label>
                                    <select name="clase" id="clasetx" class="mayusculas" onchange="funcion_subclases(this.value); funcion_pasasesion('clase',this.value);">
                                    <option value='' SELECTED>Seleccionar..</option>
                                    <?php
                                        $link_intranetpccom = con_intranetpccom();
                                        $sql ="SELECT * FROM clases where estado = 1 order by descripcion";
                                        $result64=mysql_query($sql,$link_intranetpccom) or die('Error Clase, '.mysql_error().$sql);
                                        while($row64 = mysql_fetch_array($result64)){
                                            echo "<option value='{$row64['codigoclase']}'>{$row64['descripcion']}</option>";
                                        }
                                    ?>
                                </select>
                                </div>
                            </td>
                            <td>
                                <div id="layer2_subclases"></div>
                            </td>
                            <td>
                                <div id="layer2_familias"></div>
                            </td>
                            <td>
                                <div id="layer2_modelos"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="6">
                                <label for="observacion">Otra especificacion:</label>
                                <input type="text" id="observacion" size="25" name="observacion" value="" />
                                Item:<input type="text" name="ejemTaxo" id="ejemTaxo" readonly class="mayusculas" />
                            </td>
                        </tr>
                    </table>
                
		
		
		
		<br />
        Cantidad :<input type="text" id="cantidad" size="5" name="cantidad" value="" />
		Tarifa :<input type="text" id="tarifa" size="10" name="tarifa" value="" />
        Se debe cobrar un Valor por el Alquiler/Venta/Donacion ?: <select name="cobrar" id="cobrar" size="1">
        <option value="Si">Si</option>
        <option value="No">No</option>
        </select>
		<br />
		<table border=1><tr><td>Memoria<td>Disco<td>Video<td>Red<td>Fax<td>Optico<td>Otro<td>Software</tr><tr>
		<td><input type="text" id="memoria" size="10" name="memoria" value=""></td>
		<td><input type="text" id="disco" size="10" name="disco" value=""></td>
		<td><input type="text" id="video" size="10" name="video" value=""></td>
		<td><input type="text" id="red" size="10" name="red" value=""></td>
		<td><input type="text" id="fax" size="10" name="fax" value=""></td>
		<td><input type="text" id="optico" size="10" name="optico" value=""></td>
		<td><input type="text" id="otro" size="10" name="otro" value=""></td>
		<td><input type="text" id="software" size="10" name="software" value=""></td></tr>
		</table>
		<input name="guardar" type="submit" value="Adicionar" />
		</form>

                <?php
                        $link_caweb = con_caweb();
			$transaccion=$_SESSION['caweb']['consecutivo'];
			echo  "Ultimo Item ".$_SESSION['caweb']['ultimoitem'];
                        if ($_SESSION['caweb']['resultado'] == 1) { echo "<font color=green><b> CORRECTO </b></font>"; }
                        if ($_SESSION['caweb']['resultado'] == 2) { echo "<font color=black><b> Sin datos </b></font>"; }
                        if ($_SESSION['caweb']['resultado'] == 3) { echo "<font color=red><b> INTERNO EN TRANSACCION $transaccion </b></font>"; }

			$consecutivo=$_SESSION['caweb']['consecutivo'];
			$condicion="transaccion='$consecutivo'";
                        $_SESSION["grid"]->SetDatabaseConnection($_SESSION['caweb']['basededatos'], "caweb", "caweb");

                       	$_SESSION["grid"]->SetSqlSelect('id,cantidad,pendiente,clase,item,cobrar,tarifa,memoria,disco,video,red,fax,optico,
				otro,software,observacion','temporal_ped',$condicion);
			$_SESSION["grid"]->SetUniqueDatabaseColumn("id", false);
            $_SESSION["grid"]->SetTitleName("Transaccion ($transaccion) Ingreso de Items para pedido");
			$_SESSION["grid"]->SetEditModeEdit(true);
			$_SESSION["grid"]->SetMaxRowsEachPage(15);
   			$_SESSION["grid"]->SetDatabaseColumnEditable("id", false);
			$_SESSION["grid"]->SetDatabaseColumnEditable("cantidad", true);
			$_SESSION["grid"]->SetDatabaseColumnEditable("pendiente", true);
			$_SESSION["grid"]->SetDatabaseColumnEditable("clase", false);
            $_SESSION["grid"]->SetDatabaseColumnEditable("item", false);
            $_SESSION["grid"]->SetDatabaseColumnEditable("cobrar", false);
       	    $_SESSION["grid"]->SetDatabaseColumnEditable("tarifa", true);
			$_SESSION["grid"]->SetDatabaseColumnEditable("memoria", true);
			$_SESSION["grid"]->SetDatabaseColumnEditable("disco", true);
			$_SESSION["grid"]->SetDatabaseColumnEditable("video", true);
			$_SESSION["grid"]->SetDatabaseColumnEditable("red", true);
			$_SESSION["grid"]->SetDatabaseColumnEditable("fax", true);
			$_SESSION["grid"]->SetDatabaseColumnEditable("optico", true);
			$_SESSION["grid"]->SetDatabaseColumnEditable("otro", true);
			$_SESSION["grid"]->SetDatabaseColumnEditable("software", true);
			$_SESSION["grid"]->SetDatabaseColumnEditable("observacion", true);
			$_SESSION["grid"]->SetShowExcelIco(false);
			$_SESSION["grid"]->SetShowPrintIco(true);
			$_SESSION["grid"]->PrintGrid(MODE_EDIT);
	}
                ?>
        </body> 
</html>
